#ifndef MAININFOR_H
#define MAININFOR_H

#include <QObject>
#include <QVector>
#include <QQueue>
#include <QPair>
#include <mutex>
#include <condition_variable>
#include "mytypes.h"

class MainInfor final:QObject
{
    Q_OBJECT
public:
    static MainInfor* GetInstance(QObject* parent=nullptr);
    virtual ~MainInfor();

    void SubmitInfor(Yzty::MODECODE mcode,Yzty::ITEMCODE icode,QVector<Yzty::BaceInfor*>&& infors); //提交到信息队列
                                                                                                  //然后消息分类，通知不同的信号管理类处理
    void Notify();

    const QVector<Yzty::BaceInfor*>& GetItemInfor(Yzty::MODECODE mcode,Yzty::ITEMCODE icode);

    Yzty::StatusBarInfor&   GetStatusBarInfor();                //获取状态栏信息
    void SetStatusBarInfor(const Yzty::StatusBarInfor& infor);                                   //设置状态栏信息

private:
    explicit MainInfor(QObject* parent=nullptr);
    static MainInfor* _instance;

private:
    QQueue<QPair<Yzty::MODECODE,QPair<Yzty::ITEMCODE,QVector<Yzty::BaceInfor*>>>>   _tempq;

    std::mutex                  _mutex;
    std::condition_variable     _cond;
    bool flag;

    Yzty::StatusBarInfor       _statusInfor;   //状态栏信息

};

#endif // MAININFOR_H
